﻿using System.ComponentModel.Composition;
using EnvDTE;
using TskComment.Infra;

namespace Phase0Comment
{
    [Export(typeof(BaseComment))]
    public class Phase0 : BaseComment
    {
        public override string Title
        {
            get
            {
                return "Phase0";
            }

        }

        public override string Description
        {
            get
            {
                return "";
            }

        }

        public override void Execute(DTE dte)
        {
            CodeFunction func = Function(dte);
            EditPoint startp = func.GetStartPoint(vsCMPart.vsCMPartBody).CreateEditPoint();
            TextPoint endP = func.GetEndPoint(vsCMPart.vsCMPartBody);

            string methodName = func.Name;

            while (true)
            {
                if (startp.Line == endP.Line)
                {
                    break;
                }
                startp.StartOfLine();
                startp.Insert("//");
                startp.LineDown();
            }

            Selection(dte).MoveToPoint(func.StartPoint);
            Selection(dte).StartOfLine();
            Selection(dte).NewLine();
            Selection(dte).LineUp();
            Selection(dte).Text = "//Phase0:" + methodName;
        }
    }
}
